package com.atguigu.pratice;

import java.util.Scanner;

public class GetTheBottle {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            if(n==0)return;
            int res = 0;
            //n为空瓶子数量
            while (n >= 3) {
                int m = n / 3;
                res += m;
                n = n % 3 + m;
                if (n == 2) {
                    res += 1;
                    break;
                }
            }
            System.out.println(res);
        }
    }
}
